﻿using BLL;
using IBLL;
using Ninject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;

namespace MyProject.Ioc
{
    public class NinjectRegister
    {
        private static readonly IKernel Kernel;
        static NinjectRegister()
        {
            Kernel = new StandardKernel();
            AddBindings();
        }

        public static void RegisterFovMvc()
        {
            DependencyResolver.SetResolver(new NinjectDependencyResolverForMvc(Kernel));
        }
        public static void RegisterFovWebApi(HttpConfiguration config)
        {
            config.DependencyResolver = new NinjectDependencyResolverForWebApi(Kernel);
        }

        private static void AddBindings()
        {
            Kernel.Bind<IUserInfoService>().To<UserInfoService>();
            Kernel.Bind<IArticleService>().To<ArticleService>();
            Kernel.Bind<IUserAndArticleService>().To<UserAndArticleService>();

            //Kernel.Bind<IFileHandler>().To<FileHandler>();
        }
    }
}